package com.ruoyi.jiuzai.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.jiuzai.domain.Cangkumingxi;
import com.ruoyi.jiuzai.service.ICangkumingxiService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 物资出入库明细Controller
 * 
 * @author ruoyi
 * @date 2025-06-21
 */
@RestController
@RequestMapping("/jiuzai/cangkumingxi")
public class CangkumingxiController extends BaseController
{
    @Autowired
    private ICangkumingxiService cangkumingxiService;

    /**
     * 查询物资出入库明细列表
     */
    @PreAuthorize("@ss.hasPermi('jiuzai:cangkumingxi:list')")
    @GetMapping("/list")
    public TableDataInfo list(Cangkumingxi cangkumingxi)
    {
        startPage();
        List<Cangkumingxi> list = cangkumingxiService.selectCangkumingxiList(cangkumingxi);
        return getDataTable(list);
    }

    /**
     * 导出物资出入库明细列表
     */
    @PreAuthorize("@ss.hasPermi('jiuzai:cangkumingxi:export')")
    @Log(title = "物资出入库明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Cangkumingxi cangkumingxi)
    {
        List<Cangkumingxi> list = cangkumingxiService.selectCangkumingxiList(cangkumingxi);
        ExcelUtil<Cangkumingxi> util = new ExcelUtil<Cangkumingxi>(Cangkumingxi.class);
        util.exportExcel(response, list, "物资出入库明细数据");
    }

    /**
     * 获取物资出入库明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('jiuzai:cangkumingxi:query')")
    @GetMapping(value = "/{mingId}")
    public AjaxResult getInfo(@PathVariable("mingId") Long mingId)
    {
        return success(cangkumingxiService.selectCangkumingxiByMingId(mingId));
    }

    /**
     * 新增物资出入库明细
     */
    @PreAuthorize("@ss.hasPermi('jiuzai:cangkumingxi:add')")
    @Log(title = "物资出入库明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Cangkumingxi cangkumingxi)
    {
        return toAjax(cangkumingxiService.insertCangkumingxi(cangkumingxi));
    }

    /**
     * 修改物资出入库明细
     */
    @PreAuthorize("@ss.hasPermi('jiuzai:cangkumingxi:edit')")
    @Log(title = "物资出入库明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Cangkumingxi cangkumingxi)
    {
        return toAjax(cangkumingxiService.updateCangkumingxi(cangkumingxi));
    }

    /**
     * 删除物资出入库明细
     */
    @PreAuthorize("@ss.hasPermi('jiuzai:cangkumingxi:remove')")
    @Log(title = "物资出入库明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{mingIds}")
    public AjaxResult remove(@PathVariable Long[] mingIds)
    {
        return toAjax(cangkumingxiService.deleteCangkumingxiByMingIds(mingIds));
    }
}
